package com.example.company.controller;


import com.example.company.entity.ApiResult;
import com.example.company.entity.ApiResultHandler;
import com.example.company.entity.Attendance;
import com.example.company.entity.Users;
import com.example.company.mapper.AttendanceMapper;
import com.example.company.service.IAttendanceService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 存储员工考勤记录 前端控制器
 * </p>
 *
 * @author 88Ra
 * @since 2024-12-31
 */
@RestController
@RequestMapping("/api/attendance")

public class AttendanceController {

	@Autowired
	private AttendanceMapper attendanceMapper;

	@Autowired
	private IAttendanceService iAttendanceService;
	
	@CrossOrigin
	@PostMapping("/insert")
	public ApiResult insertclock (@RequestBody Attendance attendance){
		
		
		int cur=attendanceMapper.insert(attendance);
		if (cur>= 1) {
			return ApiResultHandler.buildApiResult(200, "请求成功", attendance);
		} else {
			return ApiResultHandler.buildApiResult(400, "请求失败", null);
			
		}
	}
	
	
	@GetMapping("/list")
	public PageInfo<Attendance> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
	                                @RequestParam(defaultValue = "10") Integer pageSize,
	                                Attendance attendance) {
		
		PageInfo<Attendance> pageInfo=iAttendanceService.findPage2(pageNum, pageSize, attendance);
		return pageInfo;
	}
	

	
	
	

}
